package com.sikaryofficial.system.service.impl;

import com.sikaryofficial.system.api.model.ManualExportReq;
import com.sikaryofficial.system.api.model.user.UserDailyDTO;
import com.sikaryofficial.system.domain.SysUserDaily;
import com.sikaryofficial.system.domain.dto.TrendDTO;
import com.sikaryofficial.system.domain.dto.TrendReq;
import com.sikaryofficial.system.domain.vo.ReportTrendVO;
import com.sikaryofficial.system.mapper.SysUserDailyMapper;
import com.sikaryofficial.system.service.ISysUserDailyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 用户日活Service业务层处理
 *
 * @author qinjinyuan
 * @date 2024-04-07
 */
@Service
@Slf4j
public class SysUserDailyServiceImpl implements ISysUserDailyService {
    @Autowired
    private SysUserDailyMapper sysUserDailyMapper;

    @Override
    public void batchInsert(List<SysUserDaily> list) {
        sysUserDailyMapper.batchInsert(list);
    }

    @Override
    public List<ReportTrendVO> queryWeekly(Date startDate, Date endDate) {
        log.info("startDate:{},endDate:{}", startDate, endDate);
        return sysUserDailyMapper.queryWeekly(startDate, endDate);
    }

    @Override
    public List<ReportTrendVO> queryMonthly(Date startDate, Date endDate) {
        log.info("startDate:{},endDate:{}", startDate, endDate);
        return sysUserDailyMapper.queryMonthly(startDate, endDate);
    }

    @Override
    public List<ReportTrendVO> queryQuarterly(Date startDate, Date endDate) {
        log.info("startDate:{},endDate:{}", startDate, endDate);
        return sysUserDailyMapper.queryQuarterly(startDate, endDate);
    }

    @Override
    public List<ReportTrendVO> queryYearly(Date startDate, Date endDate) {
        log.info("startDate:{},endDate:{}", startDate, endDate);
        return sysUserDailyMapper.queryYearly(startDate, endDate);
    }

    /**
     * 更新日数据
     *
     * @param genDate
     * @param brand
     * @param subTotal
     */
    @Override
    public int saveOrUpdateDaily(Date genDate, String brand, Long subTotal, String objectId,Integer hasLogin) {
        return sysUserDailyMapper.saveOrUpdateDaily(genDate, brand, subTotal,objectId, hasLogin);
    }

    /**
     * 更新周数据
     *
     * @param weekNum
     * @param brand
     * @param subTotal
     */
    @Override
    public int saveOrUpdateWeekly(Integer weekNum, String brand, Long subTotal, Integer hasLogin) {
        return sysUserDailyMapper.saveOrUpdateWeekly(weekNum, brand, subTotal, hasLogin);
    }

    /**
     * 更新年数据
     *
     * @param genDate
     * @param brand
     * @param subTotal
     */
    @Override
    public int saveOrUpdateMonthly(Date genDate, String brand, Long subTotal, Integer hasLogin) {
        return sysUserDailyMapper.saveOrUpdateMonthly(genDate, brand, subTotal, hasLogin);
    }

    /**
     * 更新季度数据
     *
     * @param quarterNum
     * @param brand
     * @param subTotal
     */
    @Override
    public int saveOrUpdateQuarterly(Integer quarterNum, String brand, Long subTotal, Integer hasLogin) {
        return sysUserDailyMapper.saveOrUpdateQuarterly(quarterNum, brand, subTotal, hasLogin);
    }

    /**
     * 更新年数据
     *
     * @param genDate
     * @param brand
     * @param subTotal
     */
    @Override
    public int saveOrUpdateYearly(Date genDate, String brand, Long subTotal, Integer hasLogin) {
        return sysUserDailyMapper.saveOrUpdateYearly(genDate, brand, subTotal, hasLogin);
    }

    /**
     * @param req
     * @return
     */
    @Override
    public List<TrendDTO> getDailyByDate(TrendReq req) {
        return sysUserDailyMapper.getDailyByDate(req);
    }

    /**
     * @param req
     * @return
     */
    @Override
    public Long countDailyByDate(TrendReq req) {
        return sysUserDailyMapper.countDailyByDate(req);
    }

    @Override
    public List<UserDailyDTO> queryDailyByTime(ManualExportReq req) {
        return sysUserDailyMapper.queryDailyByTime(req);
    }
}
